﻿@using BootstrapBlazor.Server.Components.Samples.Table
@inject IStringLocalizer<Foo> LocalizerFoo
@inject IStringLocalizer<TablesEdit> Localizer

<div class="row form-inline g-3">
    <div class="col-12 col-sm-6">
        <BootstrapInput @bind-Value="Model.Name" />
    </div>
    <div class="col-12 col-sm-6">
        <MultiSelect @bind-Value="@Model.Hobby" Items="Hobbies" />
    </div>
    <div class="col-12">
        <Textarea @bind-Value="Model.Address" rows="3"/>
    </div>
    <div class="col-12 col-sm-6">
        <Select @bind-Value="Model.Education" />
    </div>
    <div class="col-12 col-sm-6">
        <Display Value="@EducationDesc" ShowLabel="true" DisplayText="@Localizer["TablesEditTemplateDisplayLabel"]" />
    </div>
</div>

@code {
    [Parameter]
    [NotNull]
    public Foo? Model { get; set; }

    private IEnumerable<SelectedItem>? Hobbies { get; set; }

    private string? EducationDesc => Model.Education == EnumEducation.Primary ? Localizer["TablesEditTemplateDisplayDetail1"] : Localizer["TablesEditTemplateDisplayDetail2"];

    /// <summary>
    /// <inheritdoc/>
    /// </summary>
    protected override void OnInitialized()
    {
        Hobbies = Foo.GenerateHobbies(LocalizerFoo);
    }
}
